﻿// <com.woyouqiu.Copyright>
// --------------------------------------------------------------
// <copyright>上海有求网络科技有限公司 2015</copyright>
// <Solution>MyCompany.MyProject</Solution>
// <Project>MyCompany.MyProject.Core</Project>
// <FileName>SearchEventHandler.cs</FileName>
// <CreateTime>2017-04-22 22:07</CreateTime>
// <Author>何苗</Author>
// <Email>hemiao@woyouqiu.com</Email>
// <log date="2017-04-22 22:07" version="00001">创建</log>
// --------------------------------------------------------------
// </com.woyouqiu.Copyright>

using Abp.Dependency;
using Abp.Events.Bus.Handlers;
using Abp.Threading;
using Vecen.BangChuang.BangChuang.DomainServices.Common;
using Vecen.BangChuang.BangChuang.DomainServices.EventHandlers.EventDatas;

namespace Vecen.BangChuang.BangChuang.DomainServices.EventHandlers {

    /// <summary>
    /// 搜索事件
    /// </summary>
    public class SearchEventHandler: IEventHandler<SearchEventData>, ITransientDependency {
        private readonly SearchRecordDomainService _searchRecordDomainService;

        public SearchEventHandler(SearchRecordDomainService searchRecordDomainService) {
            _searchRecordDomainService = searchRecordDomainService;
        }

        public void HandleEvent(SearchEventData eventData) {
            AsyncHelper.RunSync(async () => {
                await _searchRecordDomainService.CreateSearchRecordAsync(eventData.KeyWord);
            });
        }
    }
}